package com.lysj.admin.master.bussiness.admin.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lysj.admin.master.bussiness.admin.domain.CompanyProviderBind;
import com.lysj.admin.master.common.CommonConstant;
import com.lysj.admin.master.common.spring.mpbase.IdEntity;
import com.lysj.admin.master.common.spring.mpbase.MyService;
import com.lysj.admin.master.bussiness.admin.domain.ServiceProvider;
import com.lysj.admin.master.bussiness.admin.mapper.ServiceProviderMapper;
import com.lysj.admin.master.common.web.ParamUtil;
import com.lysj.admin.master.common.web.SelectItem;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Created by drj on 2019-12-27 14:16
 * @description
 */
@Slf4j
@Service
@Transactional
public class ServiceProviderService extends MyService<ServiceProviderMapper, ServiceProvider> {

    public List<SelectItem<String, String>> selectItemsByIds(List<String> strings) {
        return this.lambdaQuery()
                .select(ServiceProvider::getId, ServiceProvider::getName)
                .in(IdEntity::getId, ParamUtil.isBlank(strings) ? Collections.singletonList("") : strings)
                .list()
                .stream()
                .map(e -> {
                    return new SelectItem<>(e.getId(), e.getName());
                })
                .collect(Collectors.toList());
    }




}
